/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sgbd;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author g0006185
 */
public class ConnectionFactory {
    /**
     *
     * @return
     * @throws FileNotFoundException
     */
    public static Connection getConnection() throws FileNotFoundException, IOException, ClassNotFoundException, SQLException {
        String drive =  ConnectionFactory.getProp().getProperty("db.driver");
        String url =  ConnectionFactory.getProp().getProperty("db.url");
        String user =  ConnectionFactory.getProp().getProperty("db.user");
        String pwd =  ConnectionFactory.getProp().getProperty("db.pwd");
      Class.forName(drive);
      return DriverManager.getConnection(url, user, pwd);
  }
    private static Properties getProp() throws FileNotFoundException, IOException{
       Properties prop = new Properties();
       FileInputStream file = new FileInputStream("../SGBD/src/sgbd/db.properties");
       prop.load(file);
       return prop;
   }
    
}
